Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Chain Selection DropdownMenu to Backend Networks #6344

Merged
merged 6 commits into from
Dec 23, 2024

Conversation

walmat
Copy link
Contributor

@walmat walmat commented Dec 17, 2024

What changed (plus any additional context for devs)

Changes all context menus that are chain selectors to use Zeego. We now no longer rely on local ios/ assets to deliver the chain badges inside of those dropdowns and can rely on remote backend networks. These are located in three places

  1. Swaps (input filter / output filter / preferred network)
  2. Claimables
  3. AvailableNetworks on Expanded Asset Sheet

Work that's left to do

  • Need to figure out how to add hit slop into the Zeego powered DropdownMenu still
  • Probably would be a good idea to set a max height on the dropdown menu so that it doesn't overflow off the screen

Screen recordings / screenshots

https://rainbowhaus.slack.com/archives/C0468CDBE75/p1734480680880539

What to test

need to test that functionally the chain selection in all these places remains unchanged.

@walmat walmat changed the title start work on converting existing chain selection dropdowns to Zeego Convert Chain Selection DropdownMenu to Backend Networks Dec 17, 2024
@@ -75,6 +92,8 @@ export function DropdownMenu<T extends string>({
side = 'right',
alignOffset = 5,
avoidCollisions = true,
hitSlop = 12, // TODO: Figure out how to make the trigger hit slop work
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note for self

@walmat walmat marked this pull request as ready for review December 17, 2024 21:51
@brunobar79
Copy link
Member

Launch in simulator or device for 7c58c28

},
[convertAssetAndNavigate]
);
const handlePressContextMenu = useCallback((chainId: string) => convertAssetAndNavigate(+chainId), [convertAssetAndNavigate]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe (not sure if good idea) we could make convertAssetAndNavigate take string and convert inside, to not need the useCallback

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah actually just notice DropdownMenu is not memoed so the fn being stable or not does not make a difference, the useCallback is just overhead rn, don't think we can easily memo it since it takes children

},
}));

const MenuWrapper = availableChainIds.length > 1 ? ContextMenuButton : Box;
const Children = useMemo(() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

children is memo maybe it works I never tested returning components from useMemo

const backendNetworks = get().backendNetworks;
return backendNetworks.networks.reduce(
(acc, backendNetwork) => {
acc[parseInt(backendNetwork.id, 10)] = backendNetwork.icons.badgeURL;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see we do this parseInt(x, 10) sporadically why is that? what's the second arg 10 for?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can call getChainsBadgeWorklet here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's true. I will probably do a cleanup PR to this file here soon but don't want to muddy it in this PR.

@brunobar79
Copy link
Member

Launch in simulator or device for 2066fdf

Copy link
Contributor

@ibrahimtaveras00 ibrahimtaveras00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@walmat walmat changed the base branch from develop to @matthew/backend-chain-badge December 23, 2024 17:49
@walmat walmat merged commit e093c7a into @matthew/backend-chain-badge Dec 23, 2024
4 checks passed
@walmat walmat deleted the @matthew/remote-chain-selectors branch December 23, 2024 18:19
@brunobar79
Copy link
Member

Launch in simulator or device for 5709e66

derHowie pushed a commit that referenced this pull request Jan 17, 2025
* start work on backend driven chain badge

* Update src/components/expanded-state/AvailableNetworksv2.tsx

* consolidate SwapCoinIcon into RainbowCoinIcon

* replace ChainBadge with ChainImage and consolidate + cleanup

* fix missing native asset icon URL from swaps

* more badge sizing fixes

* add migration and clearing of FastImage cache in dev section to fix mainnet sizing

* fix lint

* fix up swaps

* address more swaps nuances

* more sizing issues fixed

* remove size={40} from RainbowCoinIcon as it's default

* Convert Chain Selection DropdownMenu to Backend Networks (#6344)

* start work on converting existing chain selection dropdowns to Zeego

* available networks v2 convert

* add token icons to claim dropdown and fix but with AvailableNetworks not showing ever

* latest changes to try to get hitslop to work

* refactor trending tokens to remove SwapCoinIcon and fix APP-2217

* fix APP-2218

* chain badge sizing fix on sign transaction sheet

* remove debug layouts

* fixes

* remove hitslop prop and bake it into children

* remove hitslop prop from claimable menu

* port over Kane's work for dropdown menu

* fix instances of menu item being checkbox

* Fix most chain badge issues

* Remove unrelated change

* Update src/components/expanded-state/asset/ChartExpandedState.js

* fix radial gradient color issue + spacing fix

* Fix network switcher badges

* Remove unused RainbowCoinIcon styles

* Fix EthCard mainnet icon

* Fix MintSheet chain badge

* Fix GasSpeedButton legacy network chain badge

* fix ClaimCustomization badge invalid size and position

* Fix MintsSheet chain badges

* Fix L2Disclaimer network name casing

* fix transaction details row size change

* fix SignTransactionSheet size change

* fix WalletConnectApprovalSheet position relative

* revert animated coin icon changes

* revert changes

* revert collectible send row position change

* fix WalletConnectV2ListItem

* remove change to useWallets

* fix AddCash ProviderCard

* cleanup unused vars in ClaimCustomization

* fix two coin icons sizing and position on transaction details row

---------

Co-authored-by: Ibrahim Taveras <[email protected]>
Co-authored-by: Christian Baroni <[email protected]>
ibrahimtaveras00 added a commit that referenced this pull request Jan 17, 2025
* start work on backend driven chain badge

* Update src/components/expanded-state/AvailableNetworksv2.tsx

* consolidate SwapCoinIcon into RainbowCoinIcon

* replace ChainBadge with ChainImage and consolidate + cleanup

* fix missing native asset icon URL from swaps

* more badge sizing fixes

* add migration and clearing of FastImage cache in dev section to fix mainnet sizing

* fix lint

* fix up swaps

* address more swaps nuances

* more sizing issues fixed

* remove size={40} from RainbowCoinIcon as it's default

* Convert Chain Selection DropdownMenu to Backend Networks (#6344)

* start work on converting existing chain selection dropdowns to Zeego

* available networks v2 convert

* add token icons to claim dropdown and fix but with AvailableNetworks not showing ever

* latest changes to try to get hitslop to work

* refactor trending tokens to remove SwapCoinIcon and fix APP-2217

* fix APP-2218

* chain badge sizing fix on sign transaction sheet

* remove debug layouts

* fixes

* remove hitslop prop and bake it into children

* remove hitslop prop from claimable menu

* port over Kane's work for dropdown menu

* fix instances of menu item being checkbox

* Fix most chain badge issues

* Remove unrelated change

* Update src/components/expanded-state/asset/ChartExpandedState.js

* fix radial gradient color issue + spacing fix

* Fix network switcher badges

* Remove unused RainbowCoinIcon styles

* Fix EthCard mainnet icon

* Fix MintSheet chain badge

* Fix GasSpeedButton legacy network chain badge

* fix ClaimCustomization badge invalid size and position

* Fix MintsSheet chain badges

* Fix L2Disclaimer network name casing

* fix transaction details row size change

* fix SignTransactionSheet size change

* fix WalletConnectApprovalSheet position relative

* revert animated coin icon changes

* revert changes

* revert collectible send row position change

* fix WalletConnectV2ListItem

* remove change to useWallets

* fix AddCash ProviderCard

* cleanup unused vars in ClaimCustomization

* fix two coin icons sizing and position on transaction details row

---------

Co-authored-by: Ibrahim Taveras <[email protected]>
Co-authored-by: Christian Baroni <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants